package com.xm.libretranslate.controller;

import com.xm.libretranslate.service.TranslationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

@RestController
public class TranslationController {
    @Autowired
    private TranslationService translationService;

    @Value("${libretranslate.source.lang}")
    private String sourceLang;

    @Value("${libretranslate.target.lang}")
    private String targetLang;

    @PostMapping("/translate")
    public String translate(@RequestBody Map<String, String> request) {
        String text = request.get("text");
//        String sourceLang = request.get("sourceLang");
//        String targetLang = request.get("targetLang");

        return translationService.translateText(text, sourceLang, targetLang);
    }

}